package com.itheima.d3_thread_safe.ZengTest;

/**
 * @ClassName account
 * @Author 16799
 * @Date 2025/9/22 22:47
 * @Version 1.0
 * @Description TODO
 **/
public class account {
    private String cardId;
    private double money;


    public void drawMoney(double money){
        String name = Thread.currentThread().getName();
        if (this.money >= money){
            System.out.println(name+"来取"+money+"钱成功");
            this.money-=money;
            System.out.println(name+"取钱后，剩余金额为："+this.money);
        }else {
            System.out.println(name+"来取钱，但是余额不足");
        }
    }

    public account() {
    }

    public account(String cardId, double money) {
        this.cardId = cardId;
        this.money = money;
    }

    /**
     * 获取
     * @return cardId
     */
    public String getCardId() {
        return cardId;
    }

    /**
     * 设置
     * @param cardId
     */
    public void setCardId(String cardId) {
        this.cardId = cardId;
    }

    /**
     * 获取
     * @return money
     */
    public double getMoney() {
        return money;
    }

    /**
     * 设置
     * @param money
     */
    public void setMoney(double money) {
        this.money = money;
    }

    public String toString() {
        return "account{cardId = " + cardId + ", money = " + money + "}";
    }
}
